package com.appleframework.module.usermgr.service;

import java.sql.Types;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;

import com.appleframework.core.BaseService;
import com.appleframework.module.usermgr.dao.ItemDetailMgrDao;
import com.appleframework.module.usermgr.vo.Itemdetail;

@Service("itemDetailMgrService")
public class ItemDetailMgrService extends BaseService {
	
	@Autowired
	private ItemDetailMgrDao itemDetailMgrDao;
	
	/**
     * 根据id查询
     * @param columnName
     * @param value
     * @return
     */
	public Itemdetail getItemdetailById(Integer id) {
		return itemDetailMgrDao.getItemdetailsByColunm("id", id).get(0);
	}
	
	//根据父id查询
	public List<Itemdetail>  getItemdetailsByPId(Integer parentid) {
		
		return itemDetailMgrDao.getItemdetailsByColunm("parentid", parentid);
	}
	
	/**
	 * 分页显示信息  --根据name/parentid/所有，进行分页显示
	 * @param start 记录开始
	 * @param pageSize 每页显示数
	 * @param name
	 * @param parentid 父id（菜品类别）
	 * @return
	 */
	public List<Itemdetail> getPage(Integer start, Integer pageSize,String condition,Integer parentid){
		return itemDetailMgrDao.getPage(start, pageSize, condition, parentid);
		
		
	}
	
	
	
	
	//查询所有
	public List<Itemdetail>  getItemdetails() {
		
		return itemDetailMgrDao.getItemdetails();
	}
	
	/**
	 * 添加
	 * @param itemdetail
	 */
	public void addItemdetail(Itemdetail itemdetail) {
		itemDetailMgrDao.addItemdetail(itemdetail);
	}
	
	//删除
	public void deleteItemDetail(Integer id){
		
	itemDetailMgrDao.deleteItemDetail("id", id);
	}
	
	//修改
	public void updateItem(Itemdetail itemdetail){
		
		itemDetailMgrDao.updateItem(itemdetail);
	}
	/**
	 * 按条件查询一共多少条记录  
	 * 
	 * @return 
	 */
	public int findRecordCount(String condition,Integer parentid){
		return itemDetailMgrDao.findRecordCount(condition,parentid);
	};
	

}
